package com.websystique.springsecurity.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;

import java.util.Properties;

/**
 * spring email 配置类
 */
@Configuration
@ComponentScan(basePackages = "com.websystique.springsecurity")
public class EmailConfiguration {
    @Bean(name="mailSender")
    public JavaMailSender javaMailSender(){
        JavaMailSenderImpl javaMailSenderImpl=new JavaMailSenderImpl();
        javaMailSenderImpl.setHost("smtp.qq.com");
        javaMailSenderImpl.setPort(587);
        javaMailSenderImpl.setUsername("1125502832@qq.com");
        javaMailSenderImpl.setPassword("nuuifiqwpfbnigdc");

        Properties properties=new Properties();
        properties.put("mail.smtp.starttls.enable", "true");
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.transport.protocol", "smtp");
        properties.put("mail.debug", "true");//Prints out everything on screen
        javaMailSenderImpl.setJavaMailProperties(properties);
        return javaMailSenderImpl;
    }

}
